package org.dcma.client;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class DepartamentoServiceDelegate {
	private DepartamentoServiceAsync departamentoService = GWT.create(DepartamentoService.class);
    DepartamentoGuiList gui;
    
    void listDepartamentos() {
        departamentoService.listDepartamentos(new AsyncCallback<List<Departamento>> () {
                    public void onFailure(Throwable caught) {
                        gui.service_eventListDepartamentosFailed(caught);
                    }
        
                    public void onSuccess(List<Departamento> result) {
                        gui.service_eventListRetrievedFromService(result);
                        
                    }
        }//end of inner class
        );//end of listDepartamentos method call.
    }
    
    void addDepartamento(final Departamento departamento) {
        departamentoService.addDepartamento(departamento, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventAddDepartamentoFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventAddDepartamentoSuccessful();
            }
        }//end of inner class
        );//end of addDepartamento method call.        
    }

    void updateDepartamento(final Departamento Departamento) {
        departamentoService.updateDepartamento(Departamento, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventUpdateDepartamentoFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventUpdateSuccessful();
            }
        }//end of inner class
        );//end of updateDepartamento method call.        
    }

    void removeDepartamento(final Departamento departamento) {
        departamentoService.removeDepartamento(departamento, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventRemoveDepartamentoFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventRemoveDepartamentoSuccessful();
            }
        }//end of inner class
        );//end of updateDepartamento method call.        
    }
}
